package cn.tedu.spring.di;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

//@Component
//@Controller
//@Service
@Repository
public class UserDao {

    /*
    @Value注解--依赖注入注解，注解基本类型的数值
    属性值：必须以字符串的方式注入，否学会报错。@Value("18")
         添加位置：1.添加在属性上
                  2.添加在set方法上
     @Autowired:1.添加在属性上(优先)
                  2.添加在set方法上
                  3.构造方法

     */

    @Value("jdbc:mysql://localhost:3307/tedu")
    private String url;
    @Value("root")
    private String username;
    //    @Value("root")
//    private String password;
    private String password;


    @Value("root")
public void setPassword(String password) {
    this.password = password;
}
    @Override
    public String toString() {
        return "UserDao{" +
                "url='" + url + '\'' +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                '}';
    }
}
